import $http from "axios"
import qs from 'qs'
import { Toast } from "vant";
import Vue from "vue";


Vue.use(Toast)
let up_reg = {
    state: {
        text: []
    },
    getters: {

    },
    mutations: {
        UP_REG_DATA(state, payload) {
            state.text.push(payload.data)
            // console.log(state.text);
        }
    },
    actions: {
        UP_REG(context, payload) {
            let key = qs.stringify({
                tel: payload.tel,
                password: payload.password
            })

            $http({
                url: "http://121.89.205.189:3001/api/user/dofinishregister",
                method: "POST",
                data: key
            }).then((res) => {
                console.log(res);
                if (res.data.code == 200) {
                    Toast("注册成功！");                  
                   
                    
                }else{
                    Toast("注册失败")
                }
               
                context.commit("UP_REG_DATA", { data: res.config.data })

            })

        }

    }
}
export default up_reg